<script setup lang="ts">

import {ref} from 'vue'
import {onLoad,onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app'
import {useSettingStore} from '@/store/setting'
import myParse from '@/components/loading-parse'
import useShare from '@/mixins/share'
import {shareUtils} from '@/utils/share'
const {getShareCover} = useShare()
const store = useSettingStore()
const content = ref('')
onLoad(()=>{
   content.value = store.setting.setting.pk_rich_content
})

const page = getCurrentPages().pop()
let path: string = page.route

const share_path = shareUtils.buildPathQuery(path)
onShareAppMessage(() => {

  const promise = new Promise(resolve => {
    getShareCover(path, null, null).then(res => {

      res.path = share_path

      debugger
      resolve(res)

    })
  })

  return {
    path: share_path,
    imageUrl: null,
    promise
  }
})



onShareTimeline(() => {

  const promise = new Promise(resolve => {
    getShareCover(path, null, null).then(res => {

      res.path = share_path

      debugger
      resolve(res)

    })
  })

  return {
    path: share_path,
    imageUrl: null,
    promise
  }
})

</script>

<template>
  <ForOneHeader :showLeft="false" />
  <myParse :content="content" style="width: 100vw;"></myParse>
</template>

<style scoped lang="scss"></style>
